// 手机登录

const md5 = require('./util/md5.min');
const request = require('./request');
module.exports = async query => {
  const data = {
    phone: query.phone,
    countrycode: query.countrycode || '86',
    captcha: query.captcha,
    password: md5(query.password),
    rememberLogin: 'true',
  };
  //console.log(data);
  let result;
  await request('https://music.163.com/weapi/login/cellphone', data, 'os=pc')
    .then(r => {
      result = r;
    })
    .catch(r => {
      //console.log(r);
    });

  if (result.code === 200) {
    result = {
      status: 200,
      body: {
        ...result,
      },
      cookie: result.cookie,
    };
  }
  return result;
};
